# -*- coding: UTF-8 -*-
#库存信息列表
inventory_List=[
    {"product_id":1,"product_name":"product001","purchasing_price":100,"last_purchasing_price":200,"inventory_quantity":500,"status":0,
     "goods_code":10,"selling_price":1000},
    {"product_id": 2, "product_name": "product002", "purchasing_price": 200, "last_purchasing_price":300,"inventory_quantity": 600, "status": 0,
     "goods_code": 11,"selling_price":2000},
    {"product_id": 3, "product_name": "product003", "purchasing_price": 300, "last_purchasing_price":400,"inventory_quantity": 700, "status": 0,
     "goods_code": 12,"selling_price":3000},
]
#进货入库函数
def purchase_product(product_id,purchasing_price,inventory_quantity):
    for product in inventory_List:
        if product["product_id"]==product_id:
            product["status"]=2
            product["last_purchasing_price"]=product["purchasing_price"]
            product["purchasing_price"]=purchasing_price
            product["inventory_quantity"]=product["inventory_quantity"]+inventory_quantity
            print("进货成功！")
            return

#销售出库函数
def sale_product(product_id,selling_price,quantity):
    for product in inventory_List:
        if product["product_id"] == product_id:
            product["status"] = 2
            product["selling_price"] = selling_price
            product["inventory_quantity"] = product["inventory_quantity"] - quantity
            print("出库成功！")
            return

#库存信息列表
def inventory_list_page():
    print("库存信息列表：")
    for product in inventory_List:
        print("商品编号：",product["product_id"],"商品名称：",product["product_name"],"商品编码：",product["goods_code"],
              "采购价格：",product["purchasing_price"],
              "上一次采购价格：",product["last_purchasing_price"],"库存数量：",product["inventory_quantity"],
              "状态：",product["status"],"出售价格：",product["selling_price"])
#库存管理页面
def inventory_page():
    print("库存管理页面：1.进货入库 2.销售出库")
    inventory_list_page()
    if(int(input("请输入管理模式："))==1):
        purchase_product(1, 150, 500)
        purchase_product(2, 250, 600)
        purchase_product(3, 350, 700)

    else:
        sale_product(1, 2000, 500)
        sale_product(2, 3000, 600)
        sale_product(3, 4000, 700)
    print("请输入当前库存查询模式：1.商品名称 2.商品编号")
    if(int(input())==1):
        name=input("请输入商品名称：")
        for product in inventory_List:
            if(product["product_name"]==name):
                print("商品编号：", product["product_id"], "商品名称：", product["product_name"], "商品编码：", product["goods_code"],
                      "采购价格：", product["purchasing_price"],
                      "上一次采购价格：", product["last_purchasing_price"], "库存数量：", product["inventory_quantity"],
                      "状态：", product["status"], "出售价格：", product["selling_price"])
                print("查询成功！")
                return
    else:
        code = int(input("请输入商品编号："))
        for product in inventory_List:
            if (product["goods_code"] == code):
                print("商品编号：", product["product_id"], "商品名称：", product["product_name"], "商品编码：", product["goods_code"],
                      "采购价格：", product["purchasing_price"],
                      "上一次采购价格：", product["last_purchasing_price"], "库存数量：", product["inventory_quantity"],
                      "状态：", product["status"], "出售价格：", product["selling_price"])
                print("查询成功！")
                return
if __name__ == '__main__':
    inventory_page()

